<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>用户信息维护</title>
</head>
<body>
	<form id="_form" action="/user/edit" method="post">
		<table>
			<tr>
				<th>昵称</th>
				<td><input name="nickname" value="${user.nickname }"></td>
				<td></td>
			</tr>
			<tr>
				<th>用户名</th>
				<td><input name="username" value="${user.username }"></td>
				<td></td>
			</tr>
			<tr>
				<th>密码</th>
				<td><input name="password"></td>
				<td></td>
			</tr>
			<tr>
				<th>重复密码</th>
				<td><input name="password1"></td>
				<td></td>
			</tr>
			<tr>
				<th>状态</th>
				<td><input type="checkbox" name="available"
					<c:if test="${user.available}">checked</c:if>>可用否</td>
				<td></td>
			</tr>
			<tr>
				<th>用户角色</th>
				<td colspan="2"><c:forEach items="${roles}" var="role">
						<input type="checkbox" name="roleIds" value="${role.id}"
							<c:if test="${role.isSelected}">checked</c:if>>
						${role.role} ${role.isSelected}
					</c:forEach></td>
			</tr>
			<tr>
				<td colspan="3"><input type="submit" value="提交"> <c:if
						test="${user.id == null }">
						<input type="hidden" name="_method" value="post" />
					</c:if> <c:if test="${user.id != null }">
						<input type="hidden" name="id" value="${user.id}" />
						<input type="hidden" id="_method" name="_method" value="PUT" />
						<input type="button"
							onclick="_form.action='/user/edit/${user.id}';_method.value='DELETE';submit();"
							value="刪除">
					</c:if></td>
			</tr>
		</table>
	</form>
</body>
</html>